package com.aaa.phone.controller.positioncontroller;

import com.aaa.entity.BatteryPosition;
import com.aaa.entity.Position;
import com.aaa.phone.service.postionservice.PositionService;
import com.aaa.web.commons.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/***
 * Demo class
 *
 *  @author kevin
 *  @date 2018/12/17 20:33:33
 *
 */
@Controller
@CrossOrigin
@RequestMapping("/position")
public class PositionController {

    @Autowired
    private PositionService positionService;

    /**
     * @Description: 获取附近更换电瓶站点
     * @Param: position
     * @return: List<BatteryPosition>
     * @Author: Kevin Jia
     * @Date: 2018/12/25
     * @Time: 20:50
     */
    @ResponseBody
    @RequestMapping("/getposition")
    public List<BatteryPosition> getPosition(@RequestBody Map<String, Position> position){
        return positionService.getPosition(position);
    }
    /**
     * @Description: 获取手机号码
     * @Param: phone
     * @return: String
     * @Author: Kevin Jia
     * @Date: 2018/12/25
     * @Time: 20:50
     */
    @ResponseBody
    @RequestMapping("/getservicephone")
    public Map getServicePhone(@RequestBody Map<String,String> phone){
        return positionService.getServicePhone(phone);
    }

    @ResponseBody
    @RequestMapping("/changeBatteryCount")
    public Result changeBatteryCount(String pid ){
      return   positionService.changeBatteryCount(pid);
    }

    /**
     * @Description: 
     * @Param:
     * @return: 
     * @Author: Kevin Jia
     * @Date: 2018/12/28
     * @Time: 18:53
     */
    @ResponseBody
    @RequestMapping("/getBatteryQuantity")
    public Result getBatteryQuantity(String  pid){
        System.out.println(pid);
      return   positionService.getBatteryQuantity(pid);
    }

    /**
     * @Description: 交易
     * @Param: telephone,money
     * @return: Result
     * @Author: Kevin Jia
     * @Date: 2018/12/28
     * @Time: 19:33
     */
    @ResponseBody
    @RequestMapping("/deal")
    public Result toDeal(String telephone,String money,String pid){
      return   positionService.toDeal(telephone,money,pid);
    }





}
